function f = function_symbolic_computing_2d(u, derivative)

if iscell(u)
    switch derivative
        case "dx"
            f = cellfun(@(f) matlabFunction(diff(f(sym('xi'), sym('eta')), sym('xi')), 'Vars', {sym('xi'), sym('eta')}), u, 'UniformOutput', false);

        case "dxdx"
            f = cellfun(@(f) matlabFunction(diff(f(sym('xi'), sym('eta')), sym('xi'), 2), 'Vars', {sym('xi'), sym('eta')}), u, 'UniformOutput', false);

        case "dy"
            f = cellfun(@(f) matlabFunction(diff(f(sym('xi'), sym('eta')), sym('eta')), 'Vars', {sym('xi'), sym('eta')}), u, 'UniformOutput', false);

        case "dydy"
            f = cellfun(@(f) matlabFunction(diff(f(sym('xi'), sym('eta')), sym('eta'), 2), 'Vars', {sym('xi'), sym('eta')}), u, 'UniformOutput', false);
            
        otherwise
            error('Invalid derivative type');
    end
else
    syms xi eta
    sym_u = u(xi, eta);
    switch derivative
        case "dx"
            sym_f = diff(sym_u, xi);

        case "dxdx"
            sym_f = diff(sym_u, xi, 2);

        case "dy"
            sym_f = diff(sym_u, eta);

        case "dydy"
            sym_f = diff(sym_u, eta, 2);

        otherwise
            error('Invalid derivative type');
    end
    f = matlabFunction(sym_f, 'Vars', [xi, eta]);
end

end